/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean.SOP;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;
import merlion.crm.slcm.entity.Customer;
import merlion.crm.slcm.session.SLCSessionBeanLocal;

/**
 *
 * @author Yuwei
 */
@ManagedBean(name = "scManagerBean")
@SessionScoped
public class SearchCustomerManagerBean implements Serializable{
    
    @EJB
    private SLCSessionBeanLocal sLCSessionBean; 
    private List<Customer> customers;
    private SelectItem[] categoryOptions;
    private final static String[] categories;
    
    static{
        categories = new String[2];
        categories[0] = "WholeSale";
        categories[1] = "DirectSale";
    }
    /** Creates a new instance of SearchCustomerManagerBean */
    public SearchCustomerManagerBean() {
        customers = new ArrayList<Customer>();
    }
    
     private SelectItem[] createFilterOptions(String[] data)  {  
        SelectItem[] options = new SelectItem[data.length + 1];  
  
        options[0] = new SelectItem("", "Select");  
        for(int i = 0; i < data.length; i++) {  
            options[i + 1] = new SelectItem(data[i], data[i]);  
        }  
  
        return options;  
    }

    public SelectItem[] getCategoryOptions() {
	categoryOptions = createFilterOptions(categories);
        return categoryOptions;
    }

    public void setCategoryOptions(SelectItem[] categoryOptions) {
        this.categoryOptions = categoryOptions;
    }

    public List<Customer> getCustomers() {
	customers = sLCSessionBean.getAllCustomer();
        return customers;
    }

    public void setCustomers(List<Customer> customers) {
        this.customers = customers;
    }

    public SLCSessionBeanLocal getsLCSessionBean() {
        return sLCSessionBean;
    }

    public void setsLCSessionBean(SLCSessionBeanLocal sLCSessionBean) {
        this.sLCSessionBean = sLCSessionBean;
    }


}
